package com.om.authing.event;

import com.om.authing.model.EventLog;

import java.util.Map;

public class PlayGroundEvent extends AppEvent {
    @Override
    public EventLog parseBody(EventLog eventLog) {
        System.out.println("PlayGround");
        try {
            Map body = (Map) eventLog.getBody();

            String chapterDur = body.get("chapterDur").toString();
            long chapterDurValue = chapterDur.equals("") ? 0L : Long.parseLong(chapterDur.replace(" min", ""));
            body.put("chapterDur", chapterDurValue);

            String courseDur = body.get("courseDur").toString();
            long courseDurValue = chapterDur.equals("") ? 0L : Long.parseLong(courseDur);
            body.put("courseDur", courseDurValue);

            eventLog.setBody(body);
        } catch (Exception e) {
            e.printStackTrace();
            return eventLog;
        }
        return eventLog;
    }
}
